﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:odc="clr-namespace:Odyssey.Controls" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <odc:BoolConverter x:Key="boolConverter" />

    <ControlTemplate x:Key="SelectedRibbonTabItemTemplate" TargetType="{x:Type odc:RibbonTabItem}">
        <Grid Name="grid" Margin="1,2,1,3" Height="23" Width="{TemplateBinding Width}" Focusable="False">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Path StrokeThickness="1" Margin="0,0,-2,0" SnapsToDevicePixels="False" Grid.Column="0" Focusable="False"
                    x:Name="Left" Data="M 0,23 L 3,20 L3,3 A 3,3 45 0,1 6,0 L 7,0 L 7,23"
                    Fill="{DynamicResource {ComponentResourceKey odc:Skins, RibbonTabItemBrush}}"
                    Stroke="{DynamicResource {ComponentResourceKey odc:Skins, DefaultBorderBrush}}" />

            <Path StrokeThickness="1" Margin="-1.5,0,0,0" SnapsToDevicePixels="False" Grid.Column="2" Focusable="False"
                    x:Name="Right" Data="M0,23 L 0,0 L 1,0 A 3,3 45 0,1 4,3 L 4,20 L7,23"
                    Fill="{DynamicResource {ComponentResourceKey odc:Skins, RibbonTabItemBrush}}"
                    Stroke="{DynamicResource {ComponentResourceKey odc:Skins, DefaultBorderBrush}}" />

            <Border BorderThickness="0,1,0,0" Grid.Column="1" Focusable="False" x:Name="Border"
                    BorderBrush="{TemplateBinding BorderBrush}"
                    Background="{TemplateBinding Background}">
                <Grid x:Name="tab">
                    <Grid x:Name="ColorBackground" Margin="-2,0,-2,0">
                        <Grid.Background>
                            <SolidColorBrush Color="{Binding Color, RelativeSource={RelativeSource TemplatedParent}}" />
                        </Grid.Background>
                        <Grid.OpacityMask>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Color="#30FFFFFF" Offset="0" />
                                <GradientStop Color="#80FFFFFF" Offset="1" />
                            </LinearGradientBrush>
                        </Grid.OpacityMask>
                    </Grid>
                    <TextBlock x:Name="tabtext" Text="{TemplateBinding Title}" VerticalAlignment="Top" Margin="4,3,4,1"
                            Focusable="False" TextTrimming="CharacterEllipsis" ToolTip="{TemplateBinding Title}"
                            Foreground="{DynamicResource {ComponentResourceKey odc:Skins, TabItemSelectedForegroundBrush}}" />
                </Grid>
            </Border>
            <Border Name="MouseOverBorder" Focusable="False" BorderBrush="#A0FFFF00" BorderThickness="3,3,3,0" 
                    CornerRadius="3,3,0,0" Margin="1,0,2,2" Grid.ColumnSpan="3" Opacity="0">
                <Border.Effect>
                    <BlurEffect KernelType="Gaussian" Radius="4" RenderingBias="Performance" />
                </Border.Effect>
            </Border>
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsMouseOver" Value="True" SourceName="tab">
                <Trigger.EnterActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity"
                                    Duration="0:0:0.25" To="1" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard>
                        <Storyboard>
                            <DoubleAnimation Storyboard.TargetName="MouseOverBorder" Storyboard.TargetProperty="Opacity"
                                    Duration="0:0:0.25" To="0" />
                        </Storyboard>
                    </BeginStoryboard>
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="IsFocused" Value="True">
                <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey odc:Skins, HighlightedRibbonBorderBrush}}" />
                <Setter Property="Background" Value="{DynamicResource {ComponentResourceKey odc:Skins, HighlightedMouseOverBtnBrush}}" />
                <Setter Property="Visibility" Value="Hidden" TargetName="ColorBackground" />
            </Trigger>
        </ControlTemplate.Triggers>

    </ControlTemplate>

    <ControlTemplate x:Key="RibbonTabItemTemplate" TargetType="{x:Type odc:RibbonTabItem}">
        <odc:RibbonChrome CornerRadius="3,3,0,0" Padding="4,0,4,0" Height="23" Margin="1,0,1,0" odc:RibbonChrome.AnimateTransition="True"
                MinWidth="8" InnerBorderThickness="0"
                MouseOverBackground="{DynamicResource {ComponentResourceKey odc:Skins, TransparentMouseOverBtnBrush}}"
                HorizontalAlignment="Stretch" RenderMouseOver="{TemplateBinding IsMouseOver}"
                RenderFlat="{Binding IsSelected, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource boolConverter}}"
                BorderThickness="1,1,1,0">
            <TextBlock Text="{TemplateBinding Title}" Margin="4,0,4,0" HorizontalAlignment="Stretch"
                    ToolTip="{TemplateBinding Title}"
                    Foreground="{DynamicResource {ComponentResourceKey odc:Skins, TabItemForegroundBrush}}"
                    TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" />
        </odc:RibbonChrome>
    </ControlTemplate>

    <Style TargetType="{x:Type odc:RibbonTabItem}">
        <Setter Property="BorderBrush" Value="{DynamicResource {ComponentResourceKey odc:Skins, DefaultBorderBrush}}" />
        <Setter Property="Background" Value="{DynamicResource {ComponentResourceKey odc:Skins, RibbonTabItemBrush}}" />
        <Setter Property="MinHeight" Value="28" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="FocusVisualStyle" Value="{x:Null}" />
        <Setter Property="Template" Value="{StaticResource RibbonTabItemTemplate}" />
        <Style.Triggers>
            <Trigger Property="IsSelected" Value="True">
                <Setter Property="Template" Value="{StaticResource SelectedRibbonTabItemTemplate}" />
            </Trigger>
        </Style.Triggers>
    </Style>
</ResourceDictionary>